import time

# from hamcrest import assert_that, close_to, contains_string
from AppWorkWxin.PO.basepage import BaseDriver
from AppWorkWxin.PO.contactpage import ContactPage
from AppWorkWxin.PO.defaultpage import DefaultPage
from AppWorkWxin.TestCase.assertthat import AssertMethod


class TestGoto():
    # 获取断言类
    assert_method = AssertMethod()
    
    
    def test_goto_commanmenu(self):
        """
        测试底部跳转菜单按钮跳转功能
        取菜单标题作为断言判断
        :return:
        """
        default_page = DefaultPage()
        # print(default_page.desired_capabilities)
        # assert_that(default_page.get_title(), contains_string("消息"))

        contact_page = default_page.goto_ContactPage()
        # assert_that(contact_page.get_title(), contains_string("吴迪迪的快乐星球"))
        # 通讯录名称复用率不高，使用特有功能：添加成员作为断言
        self.assert_method.assertthat_stringcontains(contact_page.get_title(), "添加成员")

        my_page = default_page.goto_MyPage()
        # assert_that(my_page.get_title(), contains_string("我"))
        self.assert_method.assertthat_stringcontains(my_page.get_title(), "我")
        

        work_page = default_page.goto_WorkPlantPage()
        # assert_that(work_page.get_title(), contains_string("工作台"))
        self.assert_method.assertthat_stringcontains(work_page.get_title(), "工作台")

        msg_page = default_page.goto_MessagePage()
        # assert_that(msg_page.get_title(), contains_string("消息"))
        self.assert_method.assertthat_stringcontains(msg_page.get_title(), "消息")
        
    def test_goto_addmember(self):
        """
        从通讯录页面进入添加成员菜单页
        获取特征信息进行断言
        :return: 添加成员页面
        """
        default_page = DefaultPage()
        contact_page = default_page.goto_ContactPage()
        self.assert_method.assertthat_stringcontains(contact_page.goto_AddmemberPage().get_msgtext(), "手动输入添加")
        
        # 跳转到手动输入添加页面
        current_page = contact_page.goto_AddmemberPage().get_addways("手动输入添加")
        # 退回上一页
        current_page.driver.back()

        
        
        # 跳转到从微信/手机通讯录添加
        contact_page.goto_AddmemberPage().get_addways("从微信/手机通讯录中添加")

        
        
        # 跳转到从微信/手机通讯录添加
        
        
        